package com.ytjj.qmyx.admin.controller.supplyChain;

import com.alibaba.fastjson.JSONObject;
import com.ytjj.common.utils.HttpClientUtil;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.config.SupplyApiConfig;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.ReissueLogisticsRequest;
import com.ytjj.qmyx.admin.model.request.ReissueLogisticsUpdateRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 补单管理(供应链)
 * @Version: 1.0
 */
@RestController
@RequestMapping("/reissueLogisticsBySupplyChain")
public class ReissueLogisticsBySupplyChainController {

    @Autowired
    private SupplyApiConfig supplyApiConfig;

    /**
     * 列表
     * @param reissueLogisticsRequest
     * @return
     */
    @PostMapping("/list")
    @OperLog(operModule = "供应链补单模块", operDesc = "补单查询", operType = SysLogConstants.OPERATION_SELECT)
    public String selectList(@RequestBody ReissueLogisticsRequest reissueLogisticsRequest){
        String s = HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/reissueLogistics/list",
                JSONObject.toJSONString(reissueLogisticsRequest), supplyApiConfig.getHeadsMap());
        return s;
    }

    /**
     * 修改
     * @param reissueLogisticsRequest
     * @return
     */
    @PostMapping("/updateLogistics")
    @OperLog(operModule = "供应链补单模块", operDesc = "补单编辑", operType = SysLogConstants.OPERATION_UPDATE)
    public String updateLogistics(@RequestBody ReissueLogisticsRequest reissueLogisticsRequest){
        String s = HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/reissueLogistics/updateLogistics",
                JSONObject.toJSONString(reissueLogisticsRequest), supplyApiConfig.getHeadsMap());
        return s;
    }

    /**
     * 拒绝补单
     * @param request
     * @return
     */
    @PostMapping("/refuseStatus")
    @OperLog(operModule = "供应链补单模块", operDesc = "补单拒绝", operType = SysLogConstants.OPERATION_UPDATE)
    public String refuseStatus(@RequestBody ReissueLogisticsUpdateRequest request){
        String s = HttpClientUtil.doPostJson(supplyApiConfig.getUrl() + "/reissueLogistics/refuseStatus",
                JSONObject.toJSONString(request), supplyApiConfig.getHeadsMap());
        return s;
    }
}
